package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userShopController")
@Api(tags = "用户端-店铺状态设置")
@Slf4j
@RequestMapping("/user/shop")
public class ShopController {

    @Autowired
    private RedisTemplate redisTemplate;

    //查询客户端店铺状态
    @GetMapping("/status")
    @ApiOperation("客户端店铺状态")
    public Result<Integer> getShopStatus(){
         Integer status = (Integer) redisTemplate.opsForValue().get("shop_status");
        log.info("查到店铺状态为:{}",status==1?"营业中":"打烊");
        return Result.success(status);
    }
}
